package org.qf.cloudorders;


import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.Bean;
import org.springframework.web.client.RestTemplate;

@EnableDiscoveryClient
@SpringBootApplication
// 开启OpenFeign客户端
// basePackages 填写feign接口所在的包
@EnableFeignClients(basePackages = "org.qf.cloudorders.service")
public class CloudOrdersApp {

    public static void main(String[] args) {
        SpringApplication.run(CloudOrdersApp.class, args);
    }

    @Bean
    //让ribbon拦截RestTemplate发出的所有的请求
    //ribbon获取url中的service name
    //从nacos注册中心获取实例列表
    //负责从实例列表中通过相应的负载均衡算法，获取一个实例
    //RestTemplate请求实例
    @LoadBalanced
    public RestTemplate restTemplate(){
        return new RestTemplate();
    }
}
